/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package backend;

/**
 *
 * @author Admin
 */
public class Subcategory extends Category{
    private String subcatID;

    public Subcategory(String st){
        super(st.substring(0, st.indexOf(",")));
        this.subcatID=st.substring(st.indexOf(",")+1);
    }

    
    public Subcategory(String catID, String subcatID){
        super(catID);
        this.subcatID=subcatID;
    }
    
    public String getsubID(){
        return this.subcatID;
    }

    @Override
    public String toString(){
        return super.toString()+","+subcatID;
    }

    @Override
    public boolean equals(Object o){
        if(o instanceof Subcategory){
            if(super.equals(o))
                return ((Subcategory)o).getsubID().equals(this.subcatID);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return (int) (super.hashCode() * Math.pow(3, Integer.parseInt(subcatID)));
    }

}
